package com.gitee.cirnochat.chat.model.vo.resp;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.gitee.cirnochat.chat.model.dto.ChatUser;
import com.gitee.cirnochat.chat.model.enums.SignalType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class SignalMessageResponse {
    private SignalType type; // "offer", "answer", "candidate"
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private ChatUser user; // 发送者信息
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Map<String, Object> payload; // 负载信息
    private String tip; // 对于失败或拒绝类型的提示信息

    public SignalMessageResponse(SignalType type, String tip) {
        this.type = type;
        this.tip = tip;
    }

    public static class Builder {
        private SignalType type;
        private ChatUser user;
        private Map<String, Object> payload;
        private String tip;

        public Builder type(SignalType type) {
            this.type = type;
            return this;
        }

        public Builder user(ChatUser user) {
            this.user = user;
            return this;
        }

        public Builder payload(Map<String, Object> payload) {
            this.payload = payload;
            return this;
        }

        public Builder tip(String tip) {
            this.tip = tip;
            return this;
        }

        public SignalMessageResponse build() {
            SignalMessageResponse resp = new SignalMessageResponse();
            resp.setType(type);
            resp.setUser(user);
            resp.setPayload(payload);
            resp.setTip(tip);
            return resp;
        }
    }

    public static Builder builder() {
        return new Builder();
    }

}
